
#include <string>
#include <exception> 
#include "include.h"

using std::string;
using std::exception;
void try_catch()
{
	cout<<"开始测试try_catch\n";
	cout<<"测试1\n";
	try
	{
		cout<<"AAA\n";
		string error="直接抛出错误";
		throw error;
		cout<<"BBB\n";
	}
	catch(string str)
	{
		cout<<str<<endl;
	}

    cout<<"测试2\n";
	try  
    {  
		int a[10]={};
		int b=a[1000000];//
    }  
    catch(exception &e)  
    {  
        cout << e.what() << endl;  
    }  

	cout<<"测试3\n";
	try  
    {  
        throw 3.14; //throw后面的代码将不再执行
        throw 1;   
    }  
    catch(double d)  
    {  
        cout << d << endl;  
    }  
    catch(int i)  
    {  
        cout << i << endl;  
    } 




}